/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace DaveSexton.DocProject.DocSites
{
	public struct MSHelpEntry : IEquatable<MSHelpEntry>
	{
		#region Public Properties
		public static readonly MSHelpEntry Empty = new MSHelpEntry();

		public string Title
		{
			get
			{
				return title;
			}
		}

		public string ApiLocation
		{
			get
			{
				return apiLocation;
			}
		}

		public string ApiType
		{
			get
			{
				return apiType;
			}
		}

		public string ApiName
		{
			get
			{
				return apiName;
			}
		}

		public string Locale
		{
			get
			{
				return locale;
			}
		}

		public string TopicType
		{
			get
			{
				return topicType;
			}
		}

		public string Abstract
		{
			get
			{
				return @abstract;
			}
		}
		#endregion

		#region Private / Protected
		private readonly string title, apiLocation, apiType, apiName, locale, topicType, @abstract;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="MSHelpEntry" /> class.
		/// </summary>
		public MSHelpEntry(string title, string apiLocation, string apiType, string apiName, string locale, string topicType, string @abstract)
		{
			this.title = title ?? "";
			this.apiLocation = apiLocation ?? "";
			this.apiType = apiType ?? "";
			this.apiName = apiName ?? "";
			this.locale = locale ?? "";
			this.topicType = topicType ?? "";
			this.@abstract = @abstract ?? "";
		}
		#endregion

		#region Methods
		public static bool operator ==(MSHelpEntry entry1, MSHelpEntry entry2)
		{
			return entry1.Equals(entry2);
		}

		public static bool operator !=(MSHelpEntry entry1, MSHelpEntry entry2)
		{
			return !entry1.Equals(entry2);
		}

		public override bool Equals(object obj)
		{
			if (obj is MSHelpEntry)
				return Equals((MSHelpEntry) obj);
			else
				return false;
		}

		public override int GetHashCode()
		{
			return title.GetHashCode() ^ apiLocation.GetHashCode() ^ apiType.GetHashCode() ^ 
				apiName.GetHashCode() ^ locale.GetHashCode() ^ topicType.GetHashCode() ^ @abstract.GetHashCode();
		}

		public override string ToString()
		{
			return title ?? apiName;
		}
		#endregion

		#region IEquatable<MSHelpEntry> Members
		public bool Equals(MSHelpEntry other)
		{
			return string.Equals(title, other.title, StringComparison.OrdinalIgnoreCase)
				&& string.Equals(apiLocation, other.apiLocation, StringComparison.OrdinalIgnoreCase)
				&& string.Equals(apiType, other.apiType, StringComparison.OrdinalIgnoreCase)
				&& string.Equals(apiName, other.apiName, StringComparison.OrdinalIgnoreCase)
				&& string.Equals(locale, other.locale, StringComparison.OrdinalIgnoreCase)
				&& string.Equals(topicType, other.topicType, StringComparison.OrdinalIgnoreCase)
				&& string.Equals(@abstract, other.@abstract, StringComparison.OrdinalIgnoreCase);
		}
		#endregion
	}
}
